#ifndef NNET_H
#define NNET_H

//神经网络实现  对图像
#include <QDebug>
#include <vector>
#include <iostream>
#include <cmath>
using namespace std;

struct Kernels
{
    vector<vector<vector<double>>> kernel_values;//过滤器  共filters层
    int X;//横向大小
    int Y;//竖向大小
};

struct Strides
{
    int X;//水平步长
    int Y;//竖直步长
};

struct PoolSize
{
    int X;//水平步长
    int Y;//竖直步长
};

enum Padding {valid, same};

struct CNN_net{
    Kernels kernels_C1;
    vector<double> bias_C1;

    Kernels kernels_C3;
    vector<double> bias_C3;


    vector<vector<double>> w_FC;
    vector<double> bias_FC;
};


class Nnet
{
public:
    Nnet();

    void setInput1(vector<vector<int>> img);//单通道输入
    void setInput3(vector<vector<vector<int>>> img);//三通道输入

    vector<vector<vector<double>>> convN(vector<vector<vector<double>>> input,\
                                         int filters,\
                                         Kernels kernels,\
                                         Strides strides,\
                                         Padding padding,\
                                         vector<double> bias,\
                                         bool activation);//单通道卷积

    vector<vector<vector<double>>> poolN(vector<vector<vector<double>>> input,\
                                         PoolSize poolSize,
                                         Strides strides\
                                         );

    vector<double> fc(vector<vector<vector<double>>> input,\
                      int neuronsNums,\
                      vector<vector<double>> w,\
                      vector<double> bias
                      );
    void cnn();


public:
    vector<vector<int>> Img_1;
    vector<vector<vector<int>>> Img_3;
    int Channels;
    int Height, Width;
    bool IsInput = false;
};

#endif // NNET_H
